package cn.scu.ne04jdemo.controller;

import cn.scu.ne04jdemo.entitiy.ScheProdTaskInfoEntity;
import cn.scu.ne04jdemo.entitiy.ScheTaskDevMatchInfoEntity;
import cn.scu.ne04jdemo.entitiy.ScheTimeWindowInfoEntity;
import cn.scu.ne04jdemo.service.ScheTimeWindowInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sche/timewindow/info")
public class ScheTimeWindowInfoController {

    @Autowired
    private ScheTimeWindowInfoService scheTimeWindowInfoService;

    @GetMapping("/findPage")
    public ResponseEntity<IPage> findPage(@RequestParam(defaultValue = "1") int pageNum,
                                          @RequestParam(defaultValue = "10") int pageSize) {
        QueryWrapper<ScheTimeWindowInfoEntity> params = new QueryWrapper();
        IPage<ScheTimeWindowInfoEntity> page = scheTimeWindowInfoService.page(new Page<>(pageNum, pageSize), params);
        return ResponseEntity.ok(page);
    }

    @PostMapping("/update")
    @ResponseBody
    public Boolean update(@RequestBody ScheTimeWindowInfoEntity scheTimeWindowInfoEntity){
        try {
            scheTimeWindowInfoService.updateById(scheTimeWindowInfoEntity);
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }

}
